﻿using AutoMapper;
using PcProject.Domain.IRepository;
using PcProject.Domain.Models.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PcProject.Application.Service.Bargins
{
    public class BarginService : IBarginService
    {
        /// <summary>
        /// 构造函数依赖注入
        /// </summary>
        private IBargainRepository _bargainRepository;
        private IMapper _mapper;
        /// <summary>
        /// 函数依赖注入
        /// </summary>
        /// <param name="productRepository"></param>
        /// <param name="mapper"></param>
        public BarginService(IBargainRepository bargainRepository, IMapper mapper)
        {
            _bargainRepository = bargainRepository;
            _mapper = mapper;
        }


        /// <summary>
        /// 砍价显示查询分页
        /// </summary>
        /// <returns></returns>
        public List<BargainDto> GetBargainAsync()
        {
            return _bargainRepository.GetBargainAsync();
        }

        /// <summary>
        /// 砍价添加
        /// </summary>
        /// <param name="obj">参数</param>
        /// <returns></returns>
        public async Task<int> InserAsync(Bargain obj)
        {
            return await _bargainRepository.InserAsync(obj);
        }

        /// <summary>
        /// 砍价删除
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        public async Task<int> DeleAsync(int id)
        {
            return await _bargainRepository.DeleAsync(id);
        }

        /// <summary>
        /// 砍价反填
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        public async Task<Bargain> FillAsync(int id)
        {
            return await _bargainRepository.FillAsync(id);
        }

        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        public BargainDto Fill(int id)
        {
            return _bargainRepository.Fill(id);
        }

        /// <summary>
        /// 砍价修改
        /// </summary>
        /// <param name="obj">参数</param>
        /// <returns></returns>
        public async Task<int> UptAsync(Bargain obj)
        {
            return await _bargainRepository.UptAsync(obj);
        }

        /// <summary>
        /// 修改价格
        /// </summary>
        /// <param name="obj">参数</param>
        /// <returns></returns>
        public int Upt(LaunchBargain obj)
        {
            return _bargainRepository.Upt(obj);
        }

    }
}
